home *** CD-ROM | disk | FTP | other *** search
- Path: news.uni-jena.de!news
- From: mkt@isun04.inf.uni-jena.de (Tilo Koerbs)
- Newsgroups: comp.lang.c++
- Subject: Re: template problem in BC++ 3.0
- Date: 2 Feb 1996 11:40:39 GMT
- Organization: Lehrstuhl fuer Rechnerarchitektur- und kommunikation, FSU Jena
- Message-ID: <4est7n$80l@fsuj01.rz.uni-jena.de>
- References: <96032.164531F0O@psuvm.psu.edu>
- Reply-To: mkt@isun04.inf.uni-jena.de
- NNTP-Posting-Host: isun07.inf.uni-jena.de
-
- This problem is well known: *** templates and separate compilation ***
-
- The compiler when comiling the template function does not know
- anything about the function calls. So it cannot generate code
- for the function (not even something like a typeless code) because
- it don't knows the types for which to compile the function.
-
- When comiling the application of the function the compiler does
- not know anything of the template function implementation.
- So the compiler is unable to generate code for the template function.
- But of course it can generate a function call!
-
- The comes the linker. It finds the function call and searches for
- the function implementation. But there is no!
- Only solution: the linker knows of templates. Then it needs a way
- to find out something about the template function implementation.
- This is usualy done by a 'template database' generated by the
- compiler whenever it meets a template in the source code.
- From this database the linker gets the information which source
- code file contains the template function implementation.
- And now? The linker calls the compiler by telling which type
- to use for the template. then the compiler compiles the code
- and returns it to the linker.
-
- You Borland C++ does not know of this technique!
-
- But as you stated, if you put all the things together in one
- translation unit, the compiler has access to all the things it
- needs to compile the template code.
-
- Bye.
- Tilo Koerbs
-
-
-
-